﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace RuleCode
{
    /// <summary>
    /// 保存当前信息的工具类
    /// </summary>
    public class CurrentUtil
    {



        #region 当前用户相关
        /// <summary>
        /// 获取或设置当前用户
        /// </summary>
        public static string UserID
        {
            get
            {
                if (HttpContext.Current.Session["UserID"] == null)
                {
                    if (HttpContext.Current.Session["UserID"] != null)
                    {
                        return HttpContext.Current.Session["UserID"].ToString();
                    }
                    return "";
                }
                return HttpContext.Current.Session["UserID"].ToString();
            }
            set
            {
                HttpContext.Current.Session["UserID"] = value;
            }
        }
        /// <summary>
        /// 获取或设置公司
        /// </summary>
        public static string CompanyID
        {
            get
            {
                if (HttpContext.Current.Session["CompanyID"] == null)
                {
                    if (HttpContext.Current.Session["CompanyID"] != null)
                    {
                        return HttpContext.Current.Session["CompanyID"].ToString();
                    }
                    return "";
                }
                return HttpContext.Current.Session["CompanyID"].ToString();
            }
            set
            {
                HttpContext.Current.Session["CompanyID"] = value;
            }
        }

        #endregion



        public static double str2double(string str)
        {
            try
            {
                return System.Convert.ToDouble(str);
            }
            catch (Exception ex)
            {

                return 0;
            }
        }
        public static Int32 str2int(string str)
        {
            try
            {
                return System.Convert.ToInt32(str);
            }
            catch (Exception ex)
            {

                return 0;
            }
        }
    }
}
